package com.school.admin.controller;


import com.school.admin.common.result.QueryVo;
import com.school.admin.common.result.R;
import com.school.admin.entity.vo.PurviewSaveVo;
import com.school.admin.entity.vo.PurviewVo;
import com.school.admin.service.MallSysPurviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 接口权限表 前端控制器
 * </p>
 *
 * @author sunpx
 * @since 2022-03-24
 */
@RestController
@RequestMapping("/mall-sys-purview")
@Api(tags = "权限/绑定")
public class MallSysPurviewController {


    @Autowired
    MallSysPurviewService mallSysPurviewService;


    /**
     * 查询所有api
     * @author : sunpx
     * @param
     * @return com.school.admin.common.result.R
     * @date : 2022-03-26 18:43:11
     */
    @PostMapping("getApiAll")
    @ApiOperation("查询所有api")
    public R getApiAll(@RequestBody QueryVo<PurviewVo> queryVo) {
        System.out.println(queryVo.getQueryBean().getId());
        return R.ok().data("list",mallSysPurviewService.getApiAll(queryVo.getPage(),queryVo.getQueryBean()));
    }



    @GetMapping("queryRolePurview/{id}")
    @ApiOperation("查看API详情")
    public R queryRolePurview(@PathVariable String id) {
        return R.ok().data("list",mallSysPurviewService.queryRolePurview(id));
    }



    /**
     * 绑定权限
     * @author : sunpx
     * @param purviewVo
     * @return com.school.admin.common.result.R
     * @date : 2022-03-26 19:18:16
     */
    @PostMapping("savePurview")
    @ApiOperation("绑定权限")
    public R savePurview(@RequestBody PurviewSaveVo purviewVo){
        mallSysPurviewService.savePurview(purviewVo);
        return R.ok();
    }



}

